package com.xiaozhengkeji.colastartboot.base.redis;

import com.xiaozhengkeji.colastartboot.config.RedisIndexConfig;
import org.springframework.stereotype.Service;
import wiki.xsx.core.util.RedisUtil;

import java.util.concurrent.TimeUnit;


@Service("VerifyBaseRedis")
public class VerifyBaseRedis {


    /**
     * 设置一个图形验证码
     */
    public void setVerificationCode(String date, String va) {
        // 设置Redis 60秒过期
        RedisUtil.getStringHandler(RedisIndexConfig.VerifyCodeIndex).set("GVC_" + date, va, 60, TimeUnit.SECONDS);
    }

    /**
     * 获取一个图形的验证码
     */
    public String getVerificationCode(String date) {
        return RedisUtil.getStringHandler(RedisIndexConfig.VerifyCodeIndex).get("GVC_" + date);
    }

    /**
     * 删除一个图形验证码
     */
    public void delVerificationCode(String date) {
        RedisUtil.getStringHandler(RedisIndexConfig.VerifyCodeIndex).remove("GVC_" + date);
    }
}
